<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="/js/jquery-3.3.1.min.js"></script>
    <link href="/layui/css/layui.css">
</head>
<body>
   <form  method="post">
       <input type="text" name="name" id="name" placeholder="账号"><br>
       <input type="button" id="submit" value="登录">
   </form>
   <a href="/toadd">注册</a>

   <script src="/js/jquery-3.3.1.min.js"></script>
<script>
 $("#submit").click(function () {

         var name=$("#name").val();

         if(name==null||name==""){
             alert("账号不能为空");
         } else {
             $.ajax({
                 type: 'post',
                 url: '/login'
                 , data: {
                     name: name
                 }

                 , success: function (data) {
                     console.log(data);
                     if(data.msg=="ok"){
                       location.href="/show";//去显示页面
                     }else{
                         location.href="/tologin";//去登录页面
                     }

                 }
             });
         };
 }

 )


</script>
</body>
</html>